/* Copyright (c) 2004-2024 peigen.info. All rights reserved. */

package info.peigen.hotpot.manage.core.repository.mapper;

import info.peigen.hotpot.manage.core.repository.entity.OrganizationEntity;
import info.peigen.hotpot.component.data.repository.beetlsql.mapper.AbstractBeetlSqlMapper;
import org.beetl.sql.mapper.annotation.Select;
import org.beetl.sql.mapper.annotation.Sql;
import org.beetl.sql.mapper.annotation.Template;
import org.beetl.sql.mapper.annotation.Update;

import java.lang.String;
import java.util.List;

/**
 * <b>(OrganizationMapper)</b>
 * "组织机构" 数据库映射服务
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2024-06-28
 */
@SuppressWarnings("unused")
public interface OrganizationMapper extends AbstractBeetlSqlMapper<OrganizationEntity> {
    @Template("select * from organization where id in ( #{join(ids)} )")
    @Select
    List<OrganizationEntity> listByIds(List<String> ids);

    // 唯一索引[organization_id]
    @Sql("select * from organization where organization_id = ?")
    @Select
    OrganizationEntity findByOrganizationId(String organizationId);

    @Template("select * from organization where organization_id in ( #{join(organizationIds)} )")
    @Select
    List<OrganizationEntity> listByOrganizationIds(List<String> organizationIds);

    @Sql("select * from organization where organization_id = ? for update")
    @Select
    OrganizationEntity lockByOrganizationId(String organizationId);

    @Sql("delete from organization where organization_id = ?")
    @Update
    void deleteByOrganizationId(String organizationId);

    // testUnique
    @Sql("delete from organization where name = ?")
    @Update
    void deleteByName(String name);
    @Template("delete from organization where name in ( #{join(names)} )")
    @Update
    void deleteByNames(List<String> names);

}